<script type="text/javascript">
	$(function() {
	    $.fn.dataGridOptions.formSubFun("#form",'/modules/additional/redEnvelope/redEnvelopeAdd.html',"添加成功！","添加失败！");
	});
</script>
<style>
.hide{display:none;}
.sForm .ipt{margin-left:155px;}
.sForm .ipt1{margin-bottom:20px;margin-left:155px;}
.sForm .lab{width:139px;}
</style>
<div class="popForm sForm">
    <form id="form"  method="post">
        
    	<div class="formitm">
		     <label class="lab">红包名称：</label>
		     <div class="ipt">
		     	<input type="text" name="name" class="w200 easyui-validatebox" data-options="required: true" value="" maxlength="10"/>
		     	<b>*</b>
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">是否启用：</label>
		     <div class="ipt">
		     	<input type="radio" id="status" class="xj-hongbao" value="1" name="status" checked="checked">启用
		     	<input type="radio" id="status" class="xn-hongbao" value="0" name="status">不启用
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">红包类型：</label>
		     <div class="ipt">
		     	<input type="radio" id="type" class="xj-hongbao" value="1" name="type" checked="checked">现金红包
		     	<input type="radio" id="type" class="xn-hongbao" value="2" name="type" >虚拟红包
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">发放方式：</label>
		     <div class="ipt">
		     		<select name="payType" id="payType" onchange="showPayType()">
						<option value="1">固定金额</option>
						<!--  
						<option value="2">固定比率</option>
						<option value="3">区间金额</option>
						<option value="4">区间比率</option>
						-->
					</select>
		     </div>
		</div>
		<div class="formitm hongbao-money">
		     <label class="lab">红包金额：</label>
		     <div class="ipt">
		     	<input type="text" name="amount" class="w200 easyui-validatebox"  maxlength="10" value=""/>元
		     	<b>*</b>
		     </div>
		</div>
		<div class="formitm hide hongbao-rate">
		     <label class="lab">金额比率：</label>
		     <div class="ipt">
		     	<input type="text" name="rate" id="rate" class="w200 easyui-validatebox"  maxlength="10" value=""/>%
		     	<b>*</b>
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">有效期：</label>
		     <div class="ipt">
		     	<input type="text" name="validDay" id="day" class="w200 easyui-validatebox"  maxlength="10" value=""/>天
		     </div>
		</div>
		<div class="formitm">
		     <label class="lab">红包总数：</label>
		     <div class="ipt">
		     	<input type="text" name="total" class="w200 easyui-validatebox"  maxlength="10" value=""/>个
		     </div>
		</div>
		<div class="formitm hide min_amount">
		     <label class="lab">最小金额：</label>
		     <div class="ipt">
		     	<input type="text" name="minAmount" class="w200 easyui-validatebox"  maxlength="10" value=""/>元
		     </div>
		</div>
		<div class="formitm hide max_amount">
		     <label class="lab">最大金额：</label>
		     <div class="ipt">
		     	<input type="text" name="maxAmount" class="w200 easyui-validatebox"  maxlength="10" value=""/>元
		     </div>
		</div>
		<div class="formitm" id="sectionMoney">
		<ul class="sectionMoneyList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">红包金额：</label>
				<div class="ipt"><input type="text" name="payAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
		</ul>
		<!--	S  删除列表隐藏域 -->
		<ul class="sectionMoneyList" style="display:none;">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">红包金额：</label>
				<div class="ipt"><input type="text" name="payAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
		</ul>
		<!--	E  删除列表隐藏域 -->
		<a  href="javascript:;" class="addList" title="添加">+</a>		
		</div>
		
		<div class="formitm" id="sectionRate">
		<ul class="sectionRateList">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
	
			</li>
			<li>
				<label class="lab">红包比率：</label>
				<div class="ipt"><input type="text" name="payRate" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
		</ul>
		<!--	S  删除列表隐藏域 -->
		<ul class="sectionRateList" style="display:none;">
			<li>
				<label class="lab">起始值：</label>
				<div class="ipt"><input type="text" name="startAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			
			<li>
				<label class="lab">结束值：</label>
				<div class="ipt"><input type="text" name="endAmount" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">元</div>
			</li>
			<li>
				<label class="lab">红包比率：</label>
				<div class="ipt"><input type="text" name="payRate" style="width:60px;" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" maxlength="7">%</div>
			</li>
			<li><a href="javascript:;" class="removeList" title="删除">-</a></li>
		</ul>
		<!--	E  删除列表隐藏域 -->
		<a  href="javascript:;" class="addList" title="添加">+</a>		
	</div>
	<div class="formitm">
	     <label class="lab">红包描述：</label>
	     <div class="ipt">
	     	<textarea rows="3" maxlength="250" cols="50" name="description"></textarea>
	     </div>
	</div>
	</form>
</div>
<script type="text/javascript">
	function showPayType(){
		var value = $("#payType").val();
		if(value==1){//固定金额
			$(".hongbao-rate").hide();
			$(".hongbao-money").show();
			$(".max_amount").hide();
			$(".min_amount").hide();
			$("#sectionMoney").hide();
			$("#sectionRate").hide();
			$("#sectionMoney input").attr("disabled",true);
			$("#sectionRate input").attr("disabled",true);
		}
		if(value==2){//固定比率
			$(".hongbao-rate").show();
			$(".hongbao-money").hide();
			$(".max_amount").show();
			$(".min_amount").show();
			$("#sectionMoney").hide();
			$("#sectionRate").hide();
			$("#sectionMoney input").attr("disabled",true);
			$("#sectionRate input").attr("disabled",true);
		}
		if(value==3){//区间金额
			$(".hongbao-rate").hide();
			$(".hongbao-money").hide();
			$(".max_amount").hide();
			$(".min_amount").hide();
			$("#sectionMoney").show();
			$("#sectionRate").hide();
			$("#sectionMoney input").attr("disabled",false);
			$("#sectionRate input").attr("disabled",true);
		}
		if(value==4){//区间比率
			$(".hongbao-rate").hide();
			$(".hongbao-money").hide();
			$(".max_amount").show();
			$(".min_amount").show();
			$("#sectionMoney").hide();
			$("#sectionRate").show();
			$("#sectionMoney input").attr("disabled",true);
			$("#sectionRate input").attr("disabled",false);
		}
	}
	
	showPayType();
	
	//区间金额
	var sectionMoneyStr = $("#sectionMoney .sectionMoneyList:last").prop("outerHTML");
	
	$("#sectionMoney .addList").click(function(){
		$("#sectionMoney .sectionMoneyList:last").css("display","block");
		$(this).before(sectionMoneyStr);
		$("#sectionMoney input").attr("disabled",false);
	});
	$("#sectionMoney .removeList").live("click",function(){	//	给动态生成的元素添加事件，应使用live
		 $(this).parent().parent().remove();
	});
	
	//区间比例
	var sectionRateStr = $("#sectionRate .sectionRateList:last").prop("outerHTML");
	
	$("#sectionRate .addList").click(function(){
		$("#sectionRate .sectionRateList:last").css("display","block");
		$(this).before(sectionRateStr);
		$("#sectionRate input").attr("disabled",false);
	});
	$("#sectionRate .removeList").live("click",function(){	//	给动态生成的元素添加事件，应使用live
		 $(this).parent().parent().remove();
	});
	</script>
